export {}

// 可选参数
function add(a: number,b?: number):number{
    return a+ (b||0)
}
const res = add(2)
const res1 = add(2,3)
console.log(res, res1)

// 无返回值

function add2(list:number[]):void {
    list.forEach(item=>{
        if(item>3){
            console.log(item)
        }
    })
}

const res2 = add2([1,2,3,4,5])
console.log(22,res2)

// 练习
function arr2Str(arr:(number|string)[], str:string): string{
    return arr.join(str)
}

console.log(arr2Str([1,2,3],'-'))
console.log(arr2Str(['4','5'],'&'))